Skip to main content
Glama
hyperspell

hyperspell-mcp

Official
by hyperspell

Get Document

Retrieve specific documents from collections to access unstructured or semi-structured data for AI-powered applications.

Instructions

Get a document from a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYes

Implementation Reference

  • The handler function that fetches and returns a specific document by ID using the Hyperspell API, converting the response to a Document model.
    def get_document(document_id: int) -> Document | Error: """Get a document from a collection""" # try: r = mcp.api.documents.get(document_id=document_id) return Document.from_pydantic(r) # except APIError as e: # return Error(error=e.__class__.__name__, message=e.message)
  • Registers the get_document function as the 'Get Document' tool or resource with the MCP server.
    @mcp.tool_or_resource("document://{document_id}", name="Get Document")
  • Pydantic-compatible data class defining the schema for the Document object returned by the tool.
    class Document(BaseModel): id: int title: str type: str summary: str
  • Data class defining the schema for Error responses from the tool.
    class Error(BaseModel): error: str message: str
  • Base class used by Document and Error for converting Pydantic models from the API to data classes, used in the handler.
    @dataclass class BaseModel: @overload @classmethod def from_pydantic(cls, model: PydanticBaseModel) -> Self: ... @overload @classmethod def from_pydantic(cls, model: Sequence[PydanticBaseModel]) -> list[Self]: ... @classmethod def from_pydantic( cls, model: PydanticBaseModel | Sequence[PydanticBaseModel] ) -> Self | list[Self]: """Convert a Pydantic model to a data class, selecting only the keys that are part of the data class.""" if isinstance(model, Sequence): return [cls.from_pydantic(m) for m in model] data = model.model_dump() # Only select the keys in data that are part of this data class data = {key: value for key, value in data.items() if key in cls.__annotations__} return cls(**data)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hyperspell/hyperspell-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server